<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>科目一</title>
    <link href="../../layui/css/layui.css" rel="stylesheet">
    <!--<link href="css/layuiAdmin.css" rel="stylesheet">-->
    <link href="../../static/css/style.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <script src="../../static/js/html5.js"></script>
    <script src="../../static/js/respond.js"></script>
    <![endif]-->

</head>
<body>

<!--主体内容-->
<div class="layui-fluid">
    <div class="layui-card content-wrap">
        <!--查询-->
        <form class="layui-form  layui-form-pane layui-form-item">
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md3 layui-col-sm6">
                    <label class="layui-form-label">学员列表</label>
                    <div class="layui-input-block">
                        <input type="text" id="NameOrNum" placeholder="请输入学员姓名或证件号码" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-col-md3 layui-col-sm6">
                    <label class="layui-form-label">报名机构</label>
                    <div class="layui-input-block">
                        <input type="text"  id="driverName" placeholder="请输入报名机构" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline layui-col-md3 layui-col-sm6">
                    <label class="layui-form-label">准驾车型</label>
                    <div class="layui-input-block">
                        <select name="carId" id="carId">

                        </select>
                    </div>
                </div>



                <div class="layui-inline layui-col-md3 layui-col-sm6">
                    <label class="layui-form-label">时间类型</label>
                    <div class="layui-input-block">
                        <select name="timeType" id="timeType">
                            <option value="">全部</option>
                            <option value="1">创建时间</option>
                            <option value="2">考试时间</option>
                        </select>
                    </div>
                </div>

                <div class="layui-inline layui-col-md3 layui-col-sm6">
                    <label class="layui-form-label">开始时间起</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" id="timeStart" placeholder="yyyy-MM-dd">
                    </div>
                </div>

                <div class="layui-inline layui-col-md3 layui-col-sm6">
                    <label class="layui-form-label">结束时间至</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" id="timeEdd" placeholder="yyyy-MM-dd">
                    </div>
                </div>

                <div class="layui-inline layui-col-md3 layui-col-sm6">
                    <label class="layui-form-label">证件类型</label>
                    <div class="layui-input-block">
                        <select name="sfType" id="sfType">

                        </select>
                    </div>
                </div>

                <div class="layui-inline layui-col-md3 layui-col-sm6 selectButton">
                    <a  class="layui-btn add_btn" data-type="reload"  id="Recordbtn"><i class="layui-icon layui-icon-search"></i>搜索</a>
                    <a  class="layui-btn add_btn" data-type="reload"  id="Studentsbtn" style="display: none;margin-left: 0;"><i class="layui-icon layui-icon-search"></i>搜索</a>

                    <button type="reset" class="layui-btn delete_btn" data-type="reloadClean"><i class="layui-icon layui-icon-delete"></i>清空</button>
                </div>
            </div>
        </form>

        <!--数据列表展示-->
        <div class="">
            <button class="layui-btn layuiadmin-btn-useradmin add_btn ax-btn layui-btn-lg " id="k1Record" >科目一约考学员记录</button>
            <button class="layui-btn layuiadmin-btn-useradmin add_btn ax-btn layui-btn-lg btn_on" id="k1Students" >科目一学员（20）</button>
        </div>
        <div class="list">

            <div id="Record">
                <div>
                    <button class="layui-btn layuiadmin-btn-useradmin add_btn ax-btn" id="appointment" ><i class="layui-icon layui-icon-edit"></i>预约科目一考试</button>
                    <!-- <button class="layui-btn layuiadmin-btn-useradmin add_btn ax-btn" id="appointment122"><i class="layui-icon layui-icon-edit"></i>122批量约考</button> -->
                    <button class="layui-btn layuiadmin-btn-useradmin change_btn ax-btn" id="edit"><i class="layui-icon layui-icon-edit"></i>编辑</button>
                    <button class="layui-btn layuiadmin-btn-useradmin delete_btn ax-btn" id="cancel"><i class="layui-icon layui-icon-delete"></i>取消预约</button>
                    <button class="layui-btn layuiadmin-btn-useradmin add_btn ax-btn" id="pushMessageForYK">消息推送</button>
                    <button class="layui-btn layuiadmin-btn-useradmin add_btn ax-btn" id="printing">打印</button>
                </div>
                <table class="layui-hide" id="RecordTbale"
                       lay-filter="active"></table>
                <input type="hidden" id="studentName">
                <input type="hidden" id="examTime">
                <input type="hidden" id="examSubject">
            </div>

            <div id="Students" style="display: none;">
                <div>
                    <button class="layui-btn layuiadmin-btn-useradmin add_btn ax-btn" id="k1Bespeak" >分教练</button>
                    <button class="layui-btn layuiadmin-btn-useradmin add_btn ax-btn" id="pushMessageForKS">消息推送</button>
                </div>
                <table class="layui-hide" id="activeListTbale"
                       lay-filter="active"></table>
            </div>


        </div>
    </div>
</div>
<!--主体内容-->

</body>
<script src="../../static/js/jquery.min.js"></script>
<script src="../../layui/layui.js"></script>
<script src="../../static/js/base.js"></script>
<script src="../../static/js/ax.js"></script>
<script src="../../static/js/jquery.cookie.js"></script>
<script>


    var table;
    var baseData=null;
    var $;
    var qualified=null;//合格条件
    layui.use(['table','form','laydate','layer'], function() {
        $ = layui.$;
        table = layui.table;
        var form = layui.form,
            laydate = layui.laydate,
            layer=layui.layer;

        //常规用法
        laydate.render({
            elem: '#timeStart'
        });
        laydate.render({
            elem: '#timeEdd'
        });
        var Recordtab=ax.VTable({
            elem : '#RecordTbale',
            url :schoolWebUrl+'/api/studentExam/queryByStateK1',
            id: 'testReload2',
            title:'科目一约考学员记录',
            cols : [ [
                {type : 'checkbox'},
                {field : 'id', width : 80, title : '序号',type:"numbers"},
                {field : 'driverName', width : 150, title : '报名机构', sort : true},
                {field : 'studentNumber', title : '学员编号', minWidth : 150},
                {field : 'studentName', width : 100, title : '姓名', sort : true},
                {field : 'certificatesNumber', minWidth : 150, title : '证件号码', sort : true},
                {field : 'phone', minWidth : 100, title : '手机号码'},
                {field : 'sfTypeName', minWidth : 150, title : '证件类型'},
                {field : 'carName', width : 80, title : '准驾车型'},
                {field : 'examSubject', width : 100, title : '约考科目',templet:function(row,index) {
                        console.log(row.examSubject)
                        if(row.examSubject==1){
                            return '科目一'
                        }
                        if(row.examSubject==2){
                            return '科目二'
                        }
                        if(row.examSubject==3){
                            return '科目三'
                        }
                        if(row.examSubject==4){
                            return '科目四'
                        }
                    }
                },
                {field : 'examAddress', width : 150, title : '考试地点'},
                {field : 'degree', width : 80, title : '考试次数'},
                {field : 'messageStatus', width : 150, title : '消息推送'},
                {field : 'innerStatusName', width : 90, title : '业务状态'},
                // {field : '', width : 90, title : '122预约状态'},
                {field : 'operatorName', width : 100, title : '操作人'},
                {field : 'examTime', width : 150, title : '考试时间'},
                {field : 'created', width : 150, title : '创建时间'},
            ] ]

        });

        //学员预约考试

        var registers = {
            reload: function() {
                //执行重载
                table.reload('testReload2', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        nameOrNum: $('#NameOrNum').val(),
                        driverName: $('#driverName').val(),
                        carId: $('#carId').val(),
                        timeType: $('#timeType').val(),
                        timeStart: $('#timeStart').val(),
                        timeEdd: $('#timeEdd').val(),
                        sfType: $('#sfType').val(),

                    }
                })
            }
        };
        $('#Recordbtn').on('click', function(){
            var type = $(this).data('type');
            registers[type] ? registers[type].call(this) : '';
        });




        var tableIns = ax.VTable({
            elem : '#activeListTbale',
            url :schoolWebUrl+ '/api/field/queryByStateK1',
            id: 'testReload',
            title:'科目一学员列表',
            cols : [ [
                {type : 'checkbox'},
                {width : 80, title : '序号',   type:"numbers"},
                {field : 'driverName', width : 150, title : '报名机构', sort : true},
                {field : 'studentNumber', title : '学员编号', minWidth : 100},
                {field : 'studentName', minWidth : 100, title : '姓名', sort : true},
                {field : 'certificatesNumber', minWidth : 150, title : '证件号码', sort : true},
                {field : 'sfTypeName', minWidth : 80, title : '证件类型'},
                {field : 'carName', minWidth : 50, title : '准驾车型'},
                {field : 'examTime', width : 150, title : '上科考试时间'},
                //{field : 'examSubject', width : 150, title : '约考科目'},
              //  {field : 'examAddress', width : 150, title : '考试地点'},
                {field : 'degree', width : 80, title : '考试次数'},
                {field : 'fieldStatusName', width : 80, title : '是否合格'},
                {field : 'examTime', width : 150, title : '考试时间'},
            ] ]

        });



       // student = {
       //      reload : function() {
       //          //执行重载
       //          initTable(qualified);
       //      },
       //      reloadClean:function()
       //      {
       //          emptyTable();
       //      }
       //  };


        // $('#Recordbtn').on('click', function(){
        //     var type = $(this).data('type');//获取reload
        //     student[type] ? student[type].call(this) : '';
        // });

        //学员成绩列表
        var initTable=function () {
            table.reload('testReload', {
                page : {
                    curr: 1 //重新从第 1 页开始
                },
                where : {
                    // qualified:data,
                    nameOrNum : $('#NameOrNum').val(),
                    driverName : $('#driverName').val(),
                    carId : $('#carId').val(),
                    timeType :$('#timeType').val(),
                    timeStart : $('#timeStart').val(),
                    timeEdd : $('#timeEdd').val(),
                    sfType : $('#sfType').val()
                }
            });
        };

        $('#Studentsbtn').on('click', function(){
            var type = $(this).data('type');
            initTable[type] ? initTable[type].call(this) : '';
        });




        $('#k1Record').on('click', function(){
            // qualified=null;
            // initTable(qualified);
            $(this).removeClass('btn_on');
            $(this).siblings().addClass('btn_on');
            $('#Record').show().siblings().hide();
            $('#Recordbtn').show();
            $('#Studentsbtn').hide();
        });
        $('#k1Students').on('click', function(){
              // qualified="合格";
            // initTable(qualified);
            $(this).removeClass('btn_on');
            $(this).siblings().addClass('btn_on');
            $('#Students').show().siblings().hide();
            $('#Recordbtn').hide();
            $('#Studentsbtn').show();
        });

        $('#k1Bespeak').click(function () {
            top.layer.open({
                type: 2,
                title:'教练分配',
                area: ['90%', '80%'],
                fixed: true, //不固定
                maxmin: true,
                content: './school/student/coachallot.html?class='+1
            });
        });

        $("#pushMessageForYK").click(function () {
            top.layer.open({
                type: 2,
                title:'推送消息——约考结果',
                area: ['90%', '80%'],
                fixed: true, //不固定
                maxmin: true,
                content: './school/message/pushMessage.html?phase=1&pushType=1'
            });
        });
        $("#pushMessageForKS").click(function () {
            top.layer.open({
                type: 2,
                title:'推送消息——考试结果',
                area: ['90%', '80%'],
                fixed: true, //不固定
                maxmin: true,
                content: './school/message/pushMessage.html?phase=1&pushType=2'
            });
        });
        // 预约考试
        $('#appointment').click(function(){
            top.layer.open({
                type: 2,
                title:'预约科目考试',
                area: ['90%', '80%'],
                fixed: true, //不固定
                maxmin: true,
                content: './school/student/subjectYuYue.html?class='+1
            });

        })

        var initBaseData = function () {
            ax.get({
                url:schoolWebUrl+ "/api/student/getBaseData",
                success: function (res) {
                    if (res.code == 0) {
                        baseData=res.data;
                        loadBaseData();
                    } else {
                        layer.msg(res.message);
                    }
                }

            });
        };
        var loadBaseData = function () {
            // 初始  证件
            $("#sfType").empty();
            $("#sfType").append("<option value=''>请选择</option>");
            $.each(baseData.zjTypeList, function (index, zj) {
                $("#sfType").append("<option value='" + zj.id + "'>" + zj.code + "</option>");
            });

            // 准驾车型列表
            $("#carId").empty();
            $("#carId").append("<option value=''>请选择</option>");
            $.each(baseData.carTypeList, function (index, carType) {
                $("#carId").append("<option value='" + carType.id + "'>" + carType.code + "</option>");
            });
            form.render('select');

        };
        initBaseData();

        // var emptyTable=function () {
        //     $('#NameOrNum').val("");
        //     $('#driverName').val('');
        //     $('#carId').val('');
        //     $('#timeType').val('');
        //     $('#timeStart').val('');
        //     $('#timeEdd').val('');
        //     $('#sfType').val('');
        //     qualified=null;
        //     form.render('select');//重新加载select
        //     table.reload('testReload');
        // };
        //取消预约
        function removedrive() {
            var checkStatus = table.checkStatus('testReload2'), data = checkStatus.data;
            console.log(data)

            if (data.length == 0) {
                layer.alert("至少选择一条数据");
                return;
            }
            if (data.length > 1) {
                layer.alert("最多选择一条数据");
                return;
            }

            var str= encodeURI('name='+encodeURI(data[0].studentName)+'&time='+encodeURI(data[0].examTime)+'&examSubject='+encodeURI(data[0].examSubject)+'&studentid='+encodeURI(data[0].studentId));
            top.layer.open({
                type: 2,
                title:'取消预约考试',
                area: ['60%', '60%'],
                fixed: true, //不固定
                maxmin: true,
                content: './school/student/cancel.html?'+str
            })


            console.log(data)

        }
        $('#cancel').click(function () {
            removedrive();
        })
        
        
        //编辑
        function textEdit() {
            var checkStatus = table.checkStatus('testReload2'), data = checkStatus.data;
            console.log(data)

            if (data.length == 0) {
                layer.alert("至少选择一条数据");
                return;
            }
            if (data.length > 1) {
                layer.alert("最多选择一条数据");
                return;
            }

            top.layer.open({
                type: 2,
                title:'修改预约科目考试',
                area: ['90%', '80%'],
                fixed: true, //不固定
                maxmin: true,
                content: './school/student/studentEdit.html?studentId='+data[0].studentId
            });
        }
        $('#edit').click(function () {
            textEdit();
        })


    });



</script>
</html>